package com.example.openglandroidrenderer;

import android.content.Context;

/**
 * Description: OpenGL引擎
 * Created by zhangdong on 2021/7/17.
 */
public class OpenGLEngine {
    private volatile static OpenGLEngine instance;

    // 单例模式
    public static OpenGLEngine getInstance(Context context) {
        if (instance == null) {
            synchronized (OpenGLEngine.class) {
                if (instance == null) {
                    if (context != null) {
                        instance = new OpenGLEngine();
                    }
                }
            }
        }

        return instance;
    }

    private OpenGLEngine() {
        nativeCreateOpenGLEngine();
    }

    public void init() {
        nativeInit();
    }

    public void unInit() {
        nativeUninit();
    }

    public void openCamera() {
        nativeOpenCamera();
    }

    public void closeCamera() {
        nativeCloseCamera();
    }

    /********************** native 方法 *****************************/
    private static native void nativeCreateOpenGLEngine();

    private static native void nativeInit();

    private static native void nativeUninit();

    private static native void nativeOpenCamera();

    private static native void nativeCloseCamera();
}
